package com.moleq.models;

import com.moleq.db.DatabaseSchema;

public class NetworkSetting {
	// CREATE TABLE t_network_setting
	// (ns_no integer NOT NULL,
	// ns_station numeric(3,0) NOT NULL,
	// ns_name varchar(30) NULL,
	// ns_ip varchar(32) NOT NULL,
	// ns_type varchar(1) NOT NULL,-----A android W windows
	// create_datetime varchar(14) NULL,
	// update_datetime varchar(14) NULL,
	// PRIMARY KEY (ns_no));

	private int ns_no;
	private int ns_station = 0;
	private String ns_name;
	private String ns_ip;
	private String ns_type;
	private boolean isOnline = false;
	private String create_datetime;
	private String update_datetime;
	
	private boolean isLocal = false;

	public NetworkSetting() {
	}

	public NetworkSetting(int ns_no, int ns_station, String ns_name, String ns_ip, String ns_type, String create_datetime, String update_datetime) {
		this.ns_no = ns_no;
		this.ns_station = ns_station;
		this.ns_name = ns_name;
		this.ns_ip = ns_ip;
		this.ns_type = ns_type;
	}

	public NetworkSetting(int ns_no, int ns_station, String ns_name, String ns_ip, String ns_type) {
		this.ns_no = ns_no;
		this.ns_station = ns_station;
		this.ns_name = ns_name;
		this.ns_ip = ns_ip;
		this.ns_type = ns_type;

	}

	public boolean isOnline() {
		return isOnline;
	}

	public void setOnline(boolean isOnline) {
		this.isOnline = isOnline;
	}

	public int getNs_no() {
		return ns_no;
	}

	public void setNs_no(int ns_no) {
		this.ns_no = ns_no;
	}

	public int getNs_station() {
		return ns_station;
	}

	public void setNs_station(int ns_station) {
		this.ns_station = ns_station;
	}

	public String getNs_name() {
		return ns_name;
	}

	public void setNs_name(String ns_name) {
		this.ns_name = ns_name;
	}

	public String getNs_ip() {
		return ns_ip;
	}

	public void setNs_ip(String ns_ip) {
		this.ns_ip = ns_ip;
	}

	public String getNs_type() {
		return ns_type;
	}

	public void setNs_type(String ns_type) {
		this.ns_type = ns_type;
	}

	public String getCreate_datetime() {
		return create_datetime;
	}

	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}

	public String getUpdate_datetime() {
		return update_datetime;
	}

	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}

	public String getStation() {
		String result = "";
		if (ns_station > 0) {
			result = String.valueOf(ns_station);
		}
		return result;
	}

	public boolean isLocal() {
		return isLocal;
	}

	public void setLocal(boolean isLocal) {
		this.isLocal = isLocal;
	}

	// CREATE TABLE t_network_setting
		// (ns_no integer NOT NULL,
		// ns_station numeric(3,0) NOT NULL,
		// ns_name varchar(30) NULL,
		// ns_ip varchar(32) NOT NULL,
		// ns_type varchar(1) NOT NULL,-----A android W windows
		// create_datetime varchar(14) NULL,
		// update_datetime varchar(14) NULL,
	
	public String toMGData(String Action) {
		String Result = Action + "|" + DatabaseSchema.NetWorkSetting.SCHEMA_NAME
				+ "|(" + getNs_no() + "," + getNs_station() +","+CheckNull(getNs_name())+","+CheckNull(getNs_ip())+
				","+CheckNull(getNs_type())+","+ CheckNull(getCreate_datetime())+","+CheckNull(getUpdate_datetime())+")";
		return Result;
	}
	
	public String CheckNull(String value) {
		if (value == null) {
			return null;
		} else {
			return "'" + value + "'";
		}
	}

}
